# 针对单独模块调试

cmake_minimum_required(VERSION 3.16)
project(aec-demo)

add_definitions(-DWEBRTC_POSIX -DWEBRTC_AUDIO_PROCESSING_ONLY_BUILD -DWEBRTC_LINUX)

include_directories(
    ${PROJECT_SOURCE_DIR}
)

set(base_
    ${PROJECT_SOURCE_DIR}/webrtc/base/checks.cc
    ${PROJECT_SOURCE_DIR}/webrtc/base/criticalsection.cc
    ${PROJECT_SOURCE_DIR}/webrtc/base/platform_file.cc
    ${PROJECT_SOURCE_DIR}/webrtc/base/event.cc
    ${PROJECT_SOURCE_DIR}/webrtc/base/platform_thread.cc
    ${PROJECT_SOURCE_DIR}/webrtc/base/stringutils.cc
    ${PROJECT_SOURCE_DIR}/webrtc/base/thread_checker_impl.cc    
)

set(common_audio_
    # resampler
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/resampler/push_resampler.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/resampler/push_sinc_resampler.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/resampler/resampler.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/resampler/sinc_resampler.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/resampler/sinusoidal_linear_chirp_source.cc   
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/resampler/sinc_resampler_sse.cc 
    # signal processing
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/auto_correlation.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/cross_correlation_mips.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/filter_ar.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/lpc_to_refl_coef.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/resample_by_2.c 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/spl_sqrt_floor.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/auto_corr_to_refl_coef.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/cross_correlation_neon.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/filter_ar_fast_q12.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/min_max_operations.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/resample_by_2_internal.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/spl_sqrt_floor_mips.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/complex_bit_reverse.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/division_operations.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/filter_ar_fast_q12_mips.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/min_max_operations_mips.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/resample_by_2_mips.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/complex_bit_reverse_mips.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/dot_product_with_scale.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/filter_ma_fast_q12.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/min_max_operations_neon.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/resample.c 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/vector_scaling_operations.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/complex_fft.c   
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/downsample_fast.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/get_hanning_window.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/randomization_functions.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/resample_fractional.c 
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/vector_scaling_operations_mips.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/complex_fft_mips.c   
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/downsample_fast_mips.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/get_scaling_square.c 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/real_fft.c  
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/spl_init.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/copy_set_operations.c
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/downsample_fast_neon.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/ilbc_specific_functions.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/refl_coef_to_lpc.c  
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/splitting_filter.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/cross_correlation.c 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/energy.c 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/levinson_durbin.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/resample_48khz.c  
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/signal_processing/spl_sqrt.c
    # 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/audio_converter.cc 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/audio_util.cc 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/channel_buffer.cc
    # ${PROJECT_SOURCE_DIR}/webrtc/common_audio/fir_filter_neon.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/lapped_transform.cc 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/real_fourier_ooura.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/wav_file.cc 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/window_generator.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/audio_ring_buffer.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/blocker.cc 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/fir_filter.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/fir_filter_sse.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/real_fourier.cc 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/sparse_fir_filter.cc
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/wav_header.cc 
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/fft4g.c
    ${PROJECT_SOURCE_DIR}/webrtc/common_audio/ring_buffer.c
)

set(system_wrappers_    
    # system_wrappers
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/aligned_malloc.cc 
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/cpu_features.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/event.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/logging.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/file_impl.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/critical_section.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/metrics_default.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/rw_lock.cc  
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/sleep.cc 
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/thread.cc     
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/trace_impl.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/critical_section_posix.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/event_timer_posix.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/rw_lock_posix.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/thread_posix.cc
    ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/trace_posix.cc
    # ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/trace_win.cc
    # ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/condition_variable.cc     
    # ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/rw_lock_win.cc
    # ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/thread_win.cc
    # ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/condition_variable_event_win.cc     
    # ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/event_timer_win.cc      
    # ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/condition_variable_native_win.cc
    # ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/critical_section_win.cc    
    # ${PROJECT_SOURCE_DIR}/webrtc/system_wrappers/source/rw_lock_generic.cc             
)

set(modules_aec_
    # modules
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aec/aec_core.c
    # ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aec/aec_core_mips.c
    # ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aec/aec_core_neon.c
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aec/aec_core_sse2.c 
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aec/aec_rdft.c 
    # ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aec/aec_rdft_neon.c  
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aec/aec_rdft_sse2.c  
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aec/aec_resampler.c 
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aec/echo_cancellation.c

    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/utility/delay_estimator_wrapper.c
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/utility/delay_estimator.c

    ${PROJECT_SOURCE_DIR}/webrtc/common_types.cc
)

set(modules_aecm_
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aecm/aecm_core_c.c
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aecm/aecm_core.c
    ${PROJECT_SOURCE_DIR}/webrtc/modules/audio_processing/aecm/echo_control_mobile.c
)

add_executable(aecmtest aecm_test.cc ${base_} ${common_audio_} ${system_wrappers_} ${modules_aec_} ${modules_aecm_})                  
target_link_libraries(aecmtest m pthread)                                                    
               
add_executable(aectest aec_test.cc ${base_} ${common_audio_} ${system_wrappers_} ${modules_aec_} ${modules_aecm_})                  
target_link_libraries(aectest m pthread)                                                